package org.dpes.apriori;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;

class Wyniki {

	static int losowan;

	static int wybranych;

	private int wyniki[][];

	public int [][] getWyniki(String filename){
		
		List <String> listaStringow = new LinkedList<String>();
		int i=0;
		
		try {
			BufferedReader br = new BufferedReader(new FileReader(filename));
			
			while (br.ready()){
				listaStringow.add(br.readLine());
			}
			
			String [] tablicaStringow = (String [])listaStringow.toArray(new String[listaStringow.size()]);
			
			wybranych = tablicaStringow[0].split(",").length - 1;
			
			losowan = tablicaStringow.length;
			
			wyniki = new int[losowan][wybranych];
			
			for (  i = 0; i < tablicaStringow.length; i++) {
				String [] split = tablicaStringow[i].split(",");
				for (int j = 1; j < split.length; j++) {
					wyniki[i][j-1] = Integer.valueOf(split[j]);
				}
			}
		} catch (FileNotFoundException e) {
			throw new RuntimeException(e);
		} catch (IOException e) {
			throw new RuntimeException(e);
		} catch (Exception e) {
			System.out.println("problem linia - " + i);
		}
		return wyniki;
	}
}
